<?php


namespace app\services;

use think\facade\Db;
use think\facade\Config;

/**
 * Class BaseServices
 * @package app\services
 */
abstract class BaseService
{
    /**
     * 模型注入
     * @var object
     */
    protected $model;

    /**
     * 数据库事务操作
     * @param callable $closure
     * @return mixed
     */
    public function transaction(callable $closure, bool $isTran = true)
    {
        return $isTran ? Db::transaction($closure) : $closure();
    }

    /**
     * @param $name
     * @param $arguments
     * @return mixed
     */
    public function __call($name, $arguments)
    {
        // TODO: Implement __call() method.
        return call_user_func_array([$this->model, $name], $arguments);
    }
}
